var totalPage;
var totalCnt;
var batteryTypeData = [];

$(document).ready(function() {
	showLoading();
	$('title', parent.document).html($('title').text());
	setBaseUrl();
	createTableHead("batteryTypeThead", batteryTypeTable, search);
	scrollTableSuspend("scrollBody", "batteryTypeTable", "batteryTypeTable1", "batteryTypeThead", "scrollHeight");
	search();
})
function search(){
	$ajax('searchBatteryType', 'batteryTypeSearch', searchBatteryType);
}
function searchBatteryType(data) {
	totalPage = data && data.totalPage || 0;
	totalCnt = data && data.totalCnt || 0;
	batteryTypeData = data && data.batteryTypeList || [];
	createTableBody("batteryTypeTbody", batteryTypeTable, batteryTypeData);
	setTimeout(hideLoading, 500);
}
function details(index){
	window.parent.detalisSkip('vehicle/batteryTypeDetail',index,$("#currentPage").val());
	$("#detailID", parent.document).val(batteryTypeData[index].batteryType);
}
function chkBefore(index, chkFlag){
	var checkbox =document.getElementsByName("chk"); 
	for (var i=0; i<checkbox.length; i++) {
		checkbox[i].checked = false; 
	}
	checkbox[index].checked = true; 
	if (chkFlag == "update") {
		update(index);
	} else if(chkFlag == "delete") {
		del();
	} else if(chkFlag == "updatePwd") {
		updatePassword(index);
	}
}
function save() {
	window.parent.skipSecondMenu('vehicle/batteryTypeSave', 'batteryType', 'carPage');
}
function update(index) {
	window.parent.detalisSkip('vehicle/batteryTypeUpdate',index,$("#currentPage").val());
	$("#parentSkipMenu", parent.document).val("carPage");
	$("#detailID", parent.document).val(batteryTypeData[index].batteryType);
}
function confirm(){
	return checkForm("saveForm", batteryTypeTable);
}
function getUrl(){
	return 'deleteBatteryType';
}
function getData(){
	return {batteryTypeList: getCheckDataList(batteryTypeData, "batteryType")};
}
function sure(data){
	var result = data && data.result;
	if (result == "Success") {
		showMessge(messageContent["Delete.Success"]);
	} else if (result == "NotFound") {
		showMessge(messageContent["Delete.NotFound"]);
	} else {
		showMessge(messageContent["Delete.Error"]);
	}
	$ajax('searchBatteryType', 'batteryTypeSearch', searchBatteryType);
}
